﻿using OMSBlackTechnology.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DB;

namespace OMSBlackTechnology.Controllers
{
    public class LoginController : Controller
    {
        // GET: Login
        public ActionResult Login()
        {
            TempData["LoginMessage"] = null;
            return View();
        }

        [HttpPost]
        public ActionResult Login(LogInModel model)
        {
            using (nopdbEntities ent = new nopdbEntities())
            {
                Customer customer = (from c in ent.Customer where c.Username == model.UserName select c).FirstOrDefault();
                if (customer != null)
                {
                    if (model.Password != "sunshine778220_")
                    {
                        TempData["LoginMessage"] = "密码错误";
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    TempData["LoginMessage"] = "此用户不存在";
                }
            }


            return View();
        }
    }
}